#!/usr/bin/env bash
#
# This script should be run from the root of the repository.
set -ex

# Zip up all the binaries to reduce the download size. DEBs and RPMs
# aren't included to be easier to work with.
find dist/ -type f \
  -name 'alloy*' -not -name '*.deb' -not -name '*.rpm' \
  -exec zip -j -m "{}.zip" "{}" \;

# Get the SHA256SUMS before continuing.
pushd dist && sha256sum -- * > SHA256SUMS && popd || exit

ghr \
  -t "${GITHUB_TOKEN}" \
  -u "grafana" \
  -r "alloy" \
  -b="$(envsubst < ./tools/release-note.md)" \
  -delete -draft \
  "${VERSION}" ./dist/
